<#assign pageName="码表[${TableName}]管理">
<@override name="page-content">
<form class="layui-form form-horizontal" role="form" method="post" id="codetable_${tableName}_search">
    <div class="layui-form-search panel">
        <input type="text" hidden="hidden" name="_STATE"/>
        <@ctrl.TextboxQuery path="codeTable.id" labelText="按ID查询"/>
        <@ctrl.TextboxQuery path="codeTable.name" labelText="按名称查询"/>
        <div class="margin-5"> 
            <a href="javascript:;" onclick="$('form:first').submit();" class="layui-btn layui-btn-sm">
                <i class="layui-icon layui-icon-search"></i>查询
            </a>
            <a href="add" class="layui-btn layui-btn-normal layui-btn-sm">
                <i class="layui-icon layui-icon-add-1"></i>新增
            </a>
            <a href="javascript:;"  data-name="${TableName}" class="layui-btn layui-btn-warm layui-btn-sm js-report">
                <i class="layui-icon layui-icon-export"></i>导出
            </a>
            <a href="javascript:;" data-name="${TableName}" class="layui-btn layui-btn-danger layui-btn-sm js-pym">
                <i class="layui-icon layui-icon-util"></i>生成拼音码
            </a>
        </div>
    </div>
    <table class="layui-table">
        <thead>
            <tr>
                <th class="align-center" width="50px" nowrap="nowrap">序号</th>
                <th class="align-center" nowrap="nowrap">ID</th>
                <th class="align-center" nowrap="nowrap">名称</th>
                <th class="align-center layui-hide-xs">拼音码</th>
                <th class="align-center layui-hide-xs">排序</th>
                <th class="align-center" width="120px">操作</th>
            </tr>
        </thead>
        <tbody>
            <#if queryResult.rows?has_content>
                <#list queryResult.rows as dataItem>  
                <tr>
                    <td class="align-center" width="50px" nowrap="nowrap">
                        ${(pageNo-1)*pageSize+dataItem_index+1}
                    </td>
                    <td class="align-center" nowrap="nowrap">
                        ${dataItem.id}
                    </td>
                    <td nowrap="nowrap">
                        <span title="${dataItem.name}">${dataItem.name}</span>
                    </td>
                    <td class="align-center layui-hide-xs" >
                        <span title="${dataItem.pym}">${dataItem.pym}</span>
                    </td>
                    <td class="align-center layui-hide-xs" >
                        <span title="${dataItem.pxh}">${dataItem.pxh}</span>
                    </td>
                    <td class="align-center">
                        <div class="layui-table-cell">
                            <a class="layui-btn layui-btn-normal layui-btn-xs" href="edit/${dataItem.id}">
                               <i class="layui-icon layui-icon-edit"></i>编辑
                            </a> 
                            <button type="button" class="layui-btn layui-btn-danger layui-btn-xs"
                                onclick="confirmSubmit('确定要删除数据‘${dataItem.name}’吗？', {id:'${dataItem.id}'},'del')">
                                <i class="layui-icon layui-icon-delete"></i>删除
                            </button>
                        </div>
                    </td>
                </tr>
                </#list>
            <#else>
                 <tr>
                    <td colspan="6" style="color:red;text-align:center;font-weight:bold;">暂无符合条件的码表信息</td>
                 </tr>
            </#if>
            </tbody>
        </table>
        <@ctrl.pageShow (queryResult.total)!0, (queryResult.pageIndex)!0 />
    </form>
</@override>
<@override name="page-scripts">
    <script>
        $(function(){
            layui.use(['form','layer', 'jquery'], function(){
                var form=layui.form;
                var layer=layui.layer;
                var $ = layui.jquery;
                /* 生成拼音码 */
                $('.js-pym').on('click', function(){
                    var tableName = $(this).data('name');
                    confirmSubmit('您是否要重新生成表【'+tableName+'】的拼音码？', {}, '${contextPath}/codetable/'+tableName+'/pym')
                });
                /* 导出EXCEL */
                $('.js-report').on('click', function(){
                    var tableName = $(this).data('name');
                    var searchForm = $('#codetable_'+tableName+'_search');
                    var form = $('<form style="display:none;" method="post"></form>');
                    form.attr('action','${rc.getContextPath()}/codetable/'+tableName+'/export');
                    $.each(searchForm.serializeArray(), function(index) {
                        form.append($( "<input type='hidden' name='" +this['name']+"' value='"+this['value']+"'/>"));
                    });
                    form.appendTo(document.body);
                    form.submit();
                    form.remove();
                });
            })
        })
    </script>
</@override>
<@extends name="/layout/basepage.html"/> 
